package santeclair.connexion.webservice.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import santeclair.connexion.domaine.parametrage.StructureTrame;
import santeclair.connexion.parametrage.dto.StructureTrameDto;
import santeclair.connexion.parametrage.webservice.StructureTrameWebService;
import santeclair.connexion.service.echanges.StructureTrameService;
import santeclair.lunar.framework.util.BeanUtils;

/**
 * Web service de gestion des structures de trame
 * 
 * @author fmokhtari
 */
@Service
public class StructureTrameWebServiceImpl implements StructureTrameWebService {

    @Autowired
    private StructureTrameService structureTrameService;

    @Override
    public List<StructureTrameDto> getListeStructureTrame() {
        List<StructureTrame> listeStructureTrame = structureTrameService.getListeStructureTrame();
        List<StructureTrameDto> listeStructureTrameDtos = new ArrayList<>();
        for (StructureTrame structureTrame : listeStructureTrame) {
            listeStructureTrameDtos.add(BeanUtils.copyProperties(structureTrame, StructureTrameDto.class));
        }
        return listeStructureTrameDtos;
    }

    @Override
    public StructureTrameDto getStructureTrameByCode(String code) {
        return BeanUtils.copyProperties(structureTrameService.getStructureTrameByCode(code), StructureTrameDto.class);
    }

}
